/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t__jolt_analyze_direct.c                           */
/*  NOTE      =                                                    */
/*  DATE      = 2016/03/01 by songbb                               */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"

#include "../../../src/module/tuxedojolt/config.h"
#include "../test_jolt_comm.h"
#include <tuxedojolt/jolt_core.h>
#include <tuxedojolt/jolt_header.h>
#include <tuxedojolt/jolt_comm.h>
#include <tuxedojolt/jolt_packet.h>
#include <frct_comm.h>
#include <apmtest_comm.h>

extern int __jolt_analyze_direct(unsigned int ui_msgcode);

static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}

static void __case1(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_CHECKAUTH), FR_DIRECT_CLIENT2SRV);
}

static void __case2(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_DH), FR_DIRECT_CLIENT2SRV);
}

static void __case3(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_ESTCON), FR_DIRECT_CLIENT2SRV);
}

static void __case4(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_CHALLENGE), FR_DIRECT_CLIENT2SRV);
}

static void __case5(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_TICKET), FR_DIRECT_CLIENT2SRV);
}

static void __case6(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_RECONNECT), FR_DIRECT_CLIENT2SRV);
}

static void __case7(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_DATAXFER), FR_DIRECT_CLIENT2SRV);
}

static void __case8(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_CLOSE), FR_DIRECT_CLIENT2SRV);
}

static void __case9(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_CHECKAUTH + APM_JOLT_MSGCODE_REPLY), FR_DIRECT_SRV2CLIENT);
}

static void __case10(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_DH + APM_JOLT_MSGCODE_REPLY), FR_DIRECT_SRV2CLIENT);
}

static void __case11(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_ESTCON + APM_JOLT_MSGCODE_REPLY), FR_DIRECT_SRV2CLIENT);
}

static void __case12(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_CHALLENGE + APM_JOLT_MSGCODE_REPLY), FR_DIRECT_SRV2CLIENT);
}

static void __case13(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_TICKET + APM_JOLT_MSGCODE_REPLY), FR_DIRECT_SRV2CLIENT);
}

static void __case14(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_RECONNECT + APM_JOLT_MSGCODE_REPLY), FR_DIRECT_SRV2CLIENT);
}

static void __case15(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_DATAXFER + APM_JOLT_MSGCODE_REPLY), FR_DIRECT_SRV2CLIENT);
}

static void __case16(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_CLOSE + APM_JOLT_MSGCODE_REPLY), FR_DIRECT_SRV2CLIENT);
}

static void __case17(void)
{
    CU_ASSERT_EQUAL(__jolt_analyze_direct(APM_JOLT_MSGCODE_ERROR), FR_DIRECT_UNKNOWN);
}

int add_suite__jolt_analyze_direct(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" __jolt_analyze_direct()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    if (CU_add_test(pSuite, "case1", __case1) == NULL ||
        CU_add_test(pSuite, "case2", __case2) == NULL ||
        CU_add_test(pSuite, "case3", __case3) == NULL ||
        CU_add_test(pSuite, "case4", __case4) == NULL ||
        CU_add_test(pSuite, "case5", __case5) == NULL ||
        CU_add_test(pSuite, "case6", __case6) == NULL ||
        CU_add_test(pSuite, "case7", __case7) == NULL ||
        CU_add_test(pSuite, "case8", __case8) == NULL ||
        CU_add_test(pSuite, "case9", __case9) == NULL ||
        CU_add_test(pSuite, "case10", __case10) == NULL ||
        CU_add_test(pSuite, "case11", __case11) == NULL ||
        CU_add_test(pSuite, "case12", __case12) == NULL ||
        CU_add_test(pSuite, "case13", __case13) == NULL ||
        CU_add_test(pSuite, "case14", __case14) == NULL ||
        CU_add_test(pSuite, "case15", __case15) == NULL ||
        CU_add_test(pSuite, "case16", __case16) == NULL ||
        CU_add_test(pSuite, "case17", __case17) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
